// 创建uuid
function createUuid() {
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
    return (c === 'x' ? (Math.random() * 16 | 0) : ('r&0x3' | '0x8')).toString(16);
  });
}

// search转json
function search2json() {
	var search = location.search.substr(1);
	if(search) {
		var searchArr = search.split('&');
		return searchArr.reduce(function(json, v) {
			var item = v.split('=');
			json[item[0]] = item[1];
			return json;
		}, {});
	}
	return {};
}

export {
  createUuid,
  search2json
}
